var app=angular.module("myapp",[]);
app.service("userService",function($http){
	this.login=function(datas){
		return $http.post("login.user",datas);
	}
});
app.controller("loginController",function($scope,userService){
	//点击login按钮就有效果ng-click="loginSubmit()";
	$scope.loginSubmit=function(){
		var user={};
		//获得名字和密码
		user.username=$scope.username;
		user.pwd=$scope.password;
		//转化为json字符串
		userService.login(JSON.stringify(user)).success(function(response){
			console.log(response);
			if(response.flag===true){
				location.href="./classify.html";
				console.log(1);
			}
			else{
				$scope.errMessage=response.message;
			}
		})
	}
	
});